package com.ruoyi.web.controller.edh;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.edh.domain.model.EdhTeamleaderModel;
import com.ruoyi.edh.service.IEdhTeamLeaderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @version :
 * @program: easyBuy
 * @description: 易订货-团长管理
 * @author: 周爱鸿
 * @create: 2020-09-03 16:18
 **/
@RestController
@RequestMapping("edh/team/leader")
@Api(description = "易订货-团长管理")
public class EdhTeamLeaderController extends BaseController {

    @Autowired
    private IEdhTeamLeaderService teamLeaderService;

    @GetMapping("/myteam")
    @ApiOperation("我的邀请")
    public AjaxResult getMyTeam() {
        return AjaxResult.success(teamLeaderService.getMyTeam());
    }

    @GetMapping("/myLeader")
    @ApiOperation("我的团长页面所需参数")
    public AjaxResult getMyLeader() {
        return AjaxResult.success(teamLeaderService.getMyLeader());
    }


    @GetMapping("/revenueSource")
    @ApiOperation("我的收入来源")
    @ApiImplicitParam(name = "type", value = "类型 -1全部1直卖2组团", required = true, dataType = "String")
    public AjaxResult revenueSource(Integer type) {
        return AjaxResult.success(teamLeaderService.revenueSource(type));
    }

    @GetMapping("/memberDetails")
    @ApiOperation("团员详情")
    @ApiImplicitParam(name = "userId", value = "团员id", required = true, dataType = "String")
    public AjaxResult memberDetails(Long userId) {
        return AjaxResult.success(teamLeaderService.memberDetails(userId));
    }

    @GetMapping("/getList")
    @ApiOperation("获取团长列表")
    public TableDataInfo getList(EdhTeamleaderModel.SearchMiodel teamleader) {
        startPage();
        List<Map<String, Object>> list = teamLeaderService.getList(teamleader);
        return getDataTable(list);
    }

    @GetMapping("/updateLabel")
    @ApiOperation("更新团长标签")
    public AjaxResult updateLabel(EdhTeamleaderModel.Update teamleader) {
        teamLeaderService.updateLabel(teamleader);
        return AjaxResult.success("修改成功");
    }


    @GetMapping("/teamer")
    @ApiOperation("团员信息")
    public AjaxResult teamer(Long userId) {
        return AjaxResult.success(teamLeaderService.teamer(userId));
    }
}
